﻿<!doctype html>
<html>
<head>
    <title>微街秀 > 分享广告</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" type="text/css" href="css/css.css">
    <link rel="stylesheet" type="text/css" href="css/Makeresult.css">
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <style type="text/css">
        .fixedHiden{position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: black;opacity: 0.3;z-index: 99;display: none;}
    </style>
</head>
<body>
    <div>
        <div class="wamtop">
            <div class="topleft" onclick="window.location.href='MakeFt.html'">
                <img src="img/5.jpg" /></div>
            <div class="topcententxt">
                分享广告</div>
        </div>
        <div class="tg_select">           
        </div>
    </div>
      <div id="redshow" style="position: fixed; background: #DA3931; width: 240px; top: 100px; display:none;
        left: 50%; z-index: 999; border-radius: 5px; padding-bottom: 100px; margin-left: -120px;">
        <div style="background: #B22C23; width: 100%; height: 100px; border-radius: 5px;">
            <span style="font-size: 20px; float: right; margin: 8px;" id="close">×</span>
            <div style="color: white; position: absolute; top: 90px; left: 50%; width: 200px;
                margin-left: -100px; text-align: center;" class="Titletxt">
       
            </div>
        </div>
        <div style="background: #B22C23; width: 100%; height: 120px; border-bottom-left-radius: 120px;
            border-bottom-right-radius: 120px;">
        </div>
        <div style="position: absolute; top: 166px; left: 50%; margin-left: -35px;" class="Rob">
            <img src="img/Makeimg/22.png" id="Getimg" style="position: absolute; height: 80px;top: 0;">
        </div>
    </div>
    <div class="fixedHiden" style="opacity: 1; ">
    <input type="hidden" id="advrtid"  value=""/>

    <script>
        var left = -40;
        var img = document.getElementById('Getimg');
        var imgWidth = 80;
        var pi = Math.PI;
        var x = 0, temp = 0;
        var set;
        function init() {
            document.getElementById('Getimg').style.left = left + 'px';
            set = setInterval('goOn()', 1);
        }
        function goOn() {
            temp = Math.cos(x);
            document.getElementById('Getimg').style.width = Math.abs(imgWidth * temp) + 'px';
            document.getElementById('Getimg').style.left = (left + (imgWidth - Math.abs(imgWidth * temp / 2))) + 'px';
            if (temp < 0) {
                document.getElementById('Getimg').style.filter = 'FlipH(enabled:true)';
            } else {
                document.getElementById('Getimg').style.filter = 'FlipH(enabled:false)';
            }
            x += pi / 90;
        }

        var article_id = "0";   //文章ID,从推送消息进来的带ID
        var pagecount = "0";
        var page = 1;
        var keyword = "";   //关键词
        $(document).ready(function () {
            article_id = getQueryString("article_id");
            $("#close").click(function () { $(".fixedHiden").css("display", "none"); $("#redshow").css("display", "none"); });
            $("#Getimg").bind("click", qiang);
            $("#searchico").click(function () { $("#ws_tg").html(""); load(page) });

            if (navigator.userAgent.indexOf("wjx") == -1)
                Alert("请使用客户端APP");
            else {

                LoadArea();
                load(page);

                $(window).bind("scroll", function () {
                    //当滚动条滚动时
                    var scollTop = $(this).scrollTop() + $(this).height();
                    var scollH = $(document).height();
                    if (scollH - scollTop < 100) {
                        page++;
                        load(page);
                    }
                    return false;
                });

                if (article_id > 0) {
                    $("#redshow").css("display", "block");
                    $(".fixedHiden").css("display", "block");
                    $("#advrtid").val(article_id);
                }
            }
        });


        function load(page) {
            if (pagecount == "1") { return; }
            if (!islogin()) { window.location.href = 'login.html'; return; }
            keyword = $("#Stext").val();
            AjaxStart("ajax/fc_article.ashx?getlist_shared", "&page_index=" + page, function (data) {
                if (data.code == "4") { Alert(data.msg.toString()); pagecount = "1"; return; }
                if (data.code == 0) {
                    if (data.item.pageCount < page) {
                        if (pagecount == "0")
                            Alert('到底了！');
                        pagecount = "1"; return;
                    }
                    loadhtml(data);
                }
                else {
                    if (data.code == 10 || data.code == 11 || data.code == 12) {
                        Alert(data.msg);
                        setTimeout(function () { window.location.href = "makeseting.html" }, 1000);
                    }
                }
            });
        }

        function loadhtml(data) {
            $(data.item.table).each(function () {
                var link = "分享";
                var logo = this.logo == null ? "img/30.png" : this.logo;
                var picurl = this.picurl;
                var by_user_id = this.by_user_id;
                var money_id = this.money_id;
                var shared_id = this.shared_id;
                var title = this.title;
                if (title.length > 15)
                    title = title.substr(0, 15) + "...";
                if (by_user_id > 0 && (picurl == null || picurl == ''))
                    link = '上传';
                $(".tg_select").append("<div class=\"centenlist\" id=\"" + this.id + "\"><div class=\" centenimg\"><img src=\"" + logo + "\"></div><div class=\"cententxt\">" +
                    "<div class=\"cententxttop\" >" +
                    "<strong>" + title + "</strong></div>" +
                    "<div class=\"centenTime\">" + this.date.substr(0, 10) + "</div>" +
                    "<div class=\"advrtcentenflow\">" + link + "</div></div></div>");

                //红包点击
                $("#" + this.id).click(function () {
                    //之前分享了，只上传截图
                    if (by_user_id > 0 && (picurl == null || picurl == ''))
                        window.location.href = 'makeshareupload.html?id=' + shared_id + '&money_id=' + money_id;
                    else {
                        //新的分享
                        $("#redshow").css("display", "block");
                        $(".fixedHiden").css("display", "block");
                        $(".Titletxt").html($(this).find("strong").text());
                        $("#advrtid").val("");
                        $("#advrtid").val($(this).attr("id"));
                    }
                });
            });

            //推送过来的链接，直接显示抢红包界面
            if (article_id > 0)
                $(".Titletxt").html($("#" + article_id).find("strong").text());
        }

        var oldmsg = "";
        function qiang() {
            var id = $("#advrtid").val();
            if (id == "") {
                Alert("参数错误,抢红包失败!");
                return;
            }
            if (oldmsg == "账号未审核") {
                Alert(oldmsg)
                return;
            }
                  
            AjaxStart("ajax/fc_shared_money.ashx?qiang", "&article_id=" + id, function (data) {
                if (data.code == 0) {
                    $("#Getimg").bind("click", function () { Alert("正在跳转请稍等...") });
                    window.location.href = "fc_detail.aspx?article_id=" + $("#advrtid").val() + "&money_id=" + data.item;
                }
                oldmsg = data.msg;
                Alert(data.msg);
            });
        }


        function LoadArea() {
            AjaxStart("ajax/fc_setting.ashx?get", "&field=state,area1,area2,area3", function (data) {
                if (data.code != 0)
                    Alert(data.msg);
                else {
                    area1 = data.item.area1;
                    area2 = data.item.area2;
                    area3 = data.item.area3;
                }
                if (data.item.state == 0)
                    Alert("未审核的账号不能抢红包");
            });
        }


        //获取获取位置
        function LoadLocation() {           
            var param = { callback: "Call_Location", isRefresh: false };
            var p = JSON.stringify(param);            
            window.location.href = "callback://location?" + p;
        }
        var area1 = "", area2 = "", area3 = "";
        function Call_Location(jsonStr) {
            var json = jsonStr;
            if (json != null) {
                json = JSON.parse(json);
                $(".area").html(json.address)
                area1 = json.province;
                area2 = json.city;
                area3 = json.district;
            }
            else
                Alert("获取定位失败");            
        }
    </script>
</body>
</html>
